<?php
/**
*
* 功能描述（数据模型基类）
*
* @author suoya <jlusuoya@gmail.com>
* @version 1
*/

static $s_db = null;
class ModelBase
{
	public $key_eq = array();		//精确搜索关键字
	public $key_cover = array();	//转换搜索关键字
	protected $db = null;
	static public $s_db = null;
	function __construct()
	{
		global $DataBaseConf;
		global $DataBaseLogConf;
		global $s_db;
		if($s_db == null)		//仅在用DB时赋值一次
			$s_db = new PdoHelper($DataBaseConf, $DataBaseLogConf);
		$this->db = $s_db;
	}

	function DealPage(&$pageinfo, $cnt)
	{
		$pagesize = $pageinfo['size'];
		$pageinfo['cnt'] = $cnt;
		$pageinfo['pageCnt'] = ceil($cnt / $pagesize);
		$limit = $pagesize * ($pageinfo['cur'] - 1) . ", " . $pagesize;
		return $limit;
	}
}

